﻿<Page xmlns:Controls="using:Template81.Controls"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Template81.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ViewModels="using:Template81.ViewModels" 
    xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:Core="using:Microsoft.Xaml.Interactions.Core" x:Name="page" 
    x:Class="Template81.Views.AppHub"
    mc:Ignorable="d" Background="{StaticResource Color2BackgroundBrush}">

    <Page.DataContext>
        <ViewModels:AppHubViewModel />
    </Page.DataContext>

    <Page.BottomAppBar>
        <CommandBar x:Name="BottomCommandBar" RequestedTheme="{StaticResource Color2Theme}" Background="{StaticResource Color2BackgroundBrush}" BorderBrush="{StaticResource Color2BackgroundBrush}">
            <CommandBar.PrimaryCommands>
                <AppBarButton x:Uid="AppHub_RefreshAppBarButton" Label="~Refresh" Icon="Refresh" Command="{Binding RefreshCommand}"/>
                <AppBarButton x:Uid="AppHub_SettingsAppBarButton" Label="~Settings" Icon="Setting" Command="{Binding ShowSettingsUICommand}"/>
            </CommandBar.PrimaryCommands>
            <CommandBar.SecondaryCommands>
                <AppBarButton x:Uid="AppHub_ViewAppBarButton" Label="~View" Icon="View" Command="{Binding ViewFruitCommand}"/>
                <AppBarButton x:Uid="AppHub_EditAppBarButton" Label="~Edit" Icon="Edit" Command="{Binding EditFruitCommand}"/>
                <AppBarButton x:Uid="AppHub_ShareAppBarButton" Label="~Share" Icon="Send" Command="{Binding EditFruitCommand}" IsCompact="True"/>
            </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.BottomAppBar>

    <Grid>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="OrientationStateGroup">
                <VisualState x:Name="LandscapeState">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="PortraitContainer">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="PortraitState" >
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="LandscapeContainer">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Grid x:Name="PortraitContainer" Visibility="Visible">
        </Grid>

        <Grid x:Name="LandscapeContainer" Visibility="Visible">
            <Hub Background="{StaticResource Color1BackgroundBrush}" RequestedTheme="Light">
                <Hub.Header>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Rectangle Fill="{StaticResource Color2BackgroundBrush}" Margin="-40,-20,0,-20"/>
                        <Path Data="M0,0 L512.975,0 L289,108 L0,108 z" Fill="{StaticResource Color2BackgroundBrush}" Margin="-10,-20,-51,-20" Stretch="Fill" UseLayoutRounding="False" Height="108" VerticalAlignment="Bottom" Grid.Column="1" Width="50.3"/>
                        <TextBlock x:Uid="AppHub_Header" Text="~Application Header" Foreground="{StaticResource Color2ForegroundBrush}" />
                    </Grid>
                </Hub.Header>
                <HubSection Width="400" VerticalContentAlignment="Bottom">
                    <HubSection.Background>
                        <ImageBrush ImageSource="{Binding Hero.Image}" Stretch="UniformToFill" AlignmentX="Center" AlignmentY="Center" />
                    </HubSection.Background>
                    <DataTemplate>
                        <Grid Width="325" RenderTransformOrigin="0.5,0.5">
                            <Grid.RenderTransform>
                                <CompositeTransform TranslateY="-25"/>
                            </Grid.RenderTransform>
                            <Rectangle Fill="{StaticResource Color2BackgroundBrush}" Opacity=".5" />
                            <StackPanel VerticalAlignment="Bottom" Margin="20,25,20,25">
                                <TextBlock Text="{Binding Hero.Title, FallbackValue=!Title}" Style="{ThemeResource TitleTextBlockStyle}" Foreground="{StaticResource Color2ForegroundBrush}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" />
                                <TextBlock Text="{Binding Hero.Subtitle, FallbackValue=!Subtitle}" Style="{ThemeResource SubtitleTextBlockStyle}" Foreground="{StaticResource Color2ForegroundBrush}" TextWrapping="WrapWholeWords" TextTrimming="WordEllipsis" MaxLines="2" />
                            </StackPanel>
                        </Grid>
                    </DataTemplate>
                </HubSection>
                <HubSection>
                    <HubSection.Resources>
                        <CollectionViewSource x:Key="GroupedItems" Source="{Binding Items}" IsSourceGrouped="True" ItemsPath="Items"
                        d:Source="{Binding Items, Source={d:DesignInstance IsDesignTimeCreatable=True, Type=ViewModels:AppHubViewModel}}" />
                    </HubSection.Resources>
                    <DataTemplate>
                        <Controls:VariableSizedGridView 
                            SelectionChanged="GridView_SelectionChanged"
                            ItemsSource="{Binding Source={StaticResource GroupedItems}}" 
                            IsSwipeEnabled="False" SelectionMode="Single" MaxHeight="1080" 
                            BorderThickness="0" RenderTransformOrigin="0.5,0.5">
                            <Controls:VariableSizedGridView.RenderTransform>
                                <CompositeTransform TranslateY="0"/>
                            </Controls:VariableSizedGridView.RenderTransform>
                            <GridView.ItemTemplateSelector>
                                <Controls:AdTemplateSelector>
                                    <Controls:AdTemplateSelector.AdTemplate>
                                        <DataTemplate>
                                            <Grid Height="{Binding RowSpan}" Width="{Binding ColSpan}" Background="{StaticResource Color2BackgroundBrush}">
                                                <!-- advertisement -->
                                            </Grid>
                                        </DataTemplate>
                                    </Controls:AdTemplateSelector.AdTemplate>
                                    <Controls:AdTemplateSelector.DefaultTemplate>
                                        <DataTemplate>
                                            <Grid Height="{Binding RowSpan}" Width="{Binding ColSpan}">
                                                <Grid.RowDefinitions>
                                                    <RowDefinition />
                                                    <RowDefinition Height="Auto" />
                                                </Grid.RowDefinitions>
                                                <Grid.Background>
                                                    <ImageBrush ImageSource="{Binding Image}" Stretch="UniformToFill" AlignmentX="Center" AlignmentY="Center" />
                                                </Grid.Background>
                                                <Rectangle Grid.Row="1" Fill="{StaticResource Color2BackgroundBrush}" Opacity=".75" />
                                                <StackPanel Grid.Row="1" Margin="20,20,20,40">
                                                    <TextBlock Text="{Binding Title, FallbackValue=!Title}" Style="{ThemeResource TitleTextBlockStyle}" Foreground="{StaticResource Color2ForegroundBrush}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" />
                                                    <TextBlock Text="{Binding Subtitle, FallbackValue=!Subtitle}" Style="{ThemeResource SubtitleTextBlockStyle}" Foreground="{StaticResource Color2ForegroundBrush}" TextWrapping="WrapWholeWords" TextTrimming="WordEllipsis" MaxLines="2" />
                                                </StackPanel>
                                            </Grid>
                                        </DataTemplate>
                                    </Controls:AdTemplateSelector.DefaultTemplate>
                                </Controls:AdTemplateSelector>
                            </GridView.ItemTemplateSelector>
                            <GridView.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Horizontal" />
                                </ItemsPanelTemplate>
                            </GridView.ItemsPanel>
                            <GridView.GroupStyle>
                                <GroupStyle>
                                    <GroupStyle.HeaderTemplate>
                                        <DataTemplate>
                                            <TextBlock Margin="7,0,0,5" Text="{Binding Title, FallbackValue=!Title}" Foreground="{StaticResource Color1ForegroundBrush}" Style="{StaticResource SubheaderTextBlockStyle}" TextWrapping="NoWrap" />
                                        </DataTemplate>
                                    </GroupStyle.HeaderTemplate>
                                    <GroupStyle.Panel>
                                        <ItemsPanelTemplate>
                                            <VariableSizedWrapGrid ItemHeight="1" ItemWidth="1" Margin="0,0,70,0" RenderTransformOrigin="0.5,0.5" >
                                                <VariableSizedWrapGrid.RenderTransform>
                                                    <CompositeTransform TranslateY="0"/>
                                                </VariableSizedWrapGrid.RenderTransform>
                                            </VariableSizedWrapGrid>
                                        </ItemsPanelTemplate>
                                    </GroupStyle.Panel>
                                </GroupStyle>
                            </GridView.GroupStyle>
                        </Controls:VariableSizedGridView>
                    </DataTemplate>
                </HubSection>
                <HubSection>
                    <DataTemplate>
                        <!-- advertisement -->
                        <Rectangle Width="250" Height="490" Margin="0,0,0,0" Fill="{StaticResource Color1ForegroundBrush}" Opacity=".5" RenderTransformOrigin="0.5,0.5" >
                            <Rectangle.RenderTransform>
                                <CompositeTransform TranslateX="-70" TranslateY="40"/>
                            </Rectangle.RenderTransform>
                        </Rectangle>
                    </DataTemplate>
                </HubSection>
            </Hub>
            <SearchBox x:Name="MySearchBox" RequestedTheme="{StaticResource Color1Theme}" Width="32" x:Uid="AppHub_SearchBox" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,80,40,0" PlaceholderText="~Placeholder" >
                <Interactivity:Interaction.Behaviors>
                    <Core:EventTriggerBehavior EventName="GotFocus">
                        <Core:ChangePropertyAction PropertyName="Width" Value="350"/>
                    </Core:EventTriggerBehavior>
                    <Core:EventTriggerBehavior EventName="LostFocus">
                        <Core:ChangePropertyAction PropertyName="Width" Value="32"/>
                    </Core:EventTriggerBehavior>
                </Interactivity:Interaction.Behaviors>
            </SearchBox>
        </Grid>

    </Grid>
</Page>

<!-- © 2006-2014 MicrosoftGet HelpPrivacy StatementTerms of UseCode of ConductAdvertise With UsVersion 3.6.2014.20885 -->
